<template>
  <div class="page-box">
    <!-- v-if="tableList.length" -->
    <!-- <searchCom :placeholder="'请输入提交人姓名'" @searchCallBack="searchCallBack" ref="search" /> -->
    <div v-if="tableList.length==0&&isSuccess" style="top:48%" class="start-box  topCen">
      <van-button class="maxWidthPercentEighty cursor" @click='$openPage("/assessment/enterAssessment")' style="width:80%" type="info">开始考核</van-button>
    </div>
    <listCom>
      <div slot="main">
        <!--如果撤销了，则可以进行编辑重新提交 -->
        <van-cell-group @click="$openPage(item.status==10?'/assessment/enterAssessment':'/assessment/detile',item)" class="van-cell-group-box cursor" v-for="(item,index) of  tableList" :key="index">
          <van-cell :title="item.quarter_name" :value-class="state[item.status].state" :value="state[item.status].lable" :is-link="true" />
          <div v-if="item.status==2||item.status==10" @click.stop="examine_delete(item)" class="van-cell-delete error  cenCen">
            <van-icon name="delete" />
          </div>
        </van-cell-group>
      </div>
    </listCom>
    <!-- <picker :showPicker="showPicker" :columns="columns" /> -->
  </div>
</template>
<script>
// import picker from "@/components/picker/index.vue";
// ===
import service from "@/api";
import searchCom from "@/components/search/index.vue"; //搜索组件
import listCom from "@/components/list/index.vue"; //表格列表组件
import state from "@/components/js/state"; //审核状态
export default {
  components: { searchCom, listCom },
  data() {
    return {
      // columns: [], //要搜索的数组
      // showPicker: false, //展示搜索
      state: state, //审核状态
      tableList: [], //表格数据
      isSuccess: false //是否请求数据了
    };
  },
  mounted() {
    this.setRight();
    this.examine_list();
  },
  methods: {
    // 设置头部右侧按钮
    async setRight() {
      if (await this.$ddApi.isDDMobilePlatform()) {
        const res = await this.$ddApi.setRight(true, true, "设定考核指标");
        if (res) {
          this.$openPage("/assessment/enterAssessment");
        }
      } else {
        this.$store.state.navBarRight.title = "设定考核指标";
        let t = this;
        this.$store.state.navBarRight.callBackFun = function openPage() {
          t.$openPage("/assessment/enterAssessment");
        };
      }
    },
    // 搜索的换掉函数
    async searchCallBack(val) {
      console.log(val);
      this.$toast("更新中，请稍后再试");
      return;
      this.$store.state.loading = true;
      this.$store.state.loadingText = "获取数据中";
      this.isSuccess = false;
      const { data = [] } = await service.exmApproval_listByName({
        start: 0,
        limit: 999999,
        userName: val,
        current: 1
      });
      this.isSuccess = true;
      this.$store.state.loading = false;
      console.log(data.rows);
      this.tableList = data.rows || [];
    },
    // 查询
    async examine_list() {
      this.$store.state.loading = true;
      this.$store.state.loadingText = "获取数据中";
      this.isSuccess = false;
      const { data = [] } = await service.examine_list({
        start: 0,
        limit: 999999,
        current: 1
      });
      this.isSuccess = true;
      this.$store.state.loading = false;
      console.log(data.rows);
      this.tableList = data.rows || [];
      // console.log(this.$refs.search.searchValue);
    },
    // 删除数据
    async examine_delete(item) {
      const alertRes = await this.$alert("此操作将进行删除");
      if (!alertRes) {
        return;
      }
      this.$store.state.loading = true;
      this.$store.state.loadingText = "删除数据中";
      const { success = false } = await service.examine_delete({
        id: item.id
      });
      this.$store.state.loading = false;
      if (success) {
        this.$toast.success("删除成功");
        this.examine_list();
      }
    },
    demo() {
      const columns = [
        "招待费-餐饮",
        "招待费-其他",
        "办公费-办公用品",
        "办公费-快递费",
        "办公费-低值易耗品",
        "办公费-投标费",
        "办公费-车辆租赁费",
        "办公费-其他",
        "福利费-团建费",
        "福利费-公司社团报销",
        "福利费-节日福cc利",
        "福利费-水果蛋糕",
        "福利cc费-其他",
        "市场推广费-商城aa推广费",
        "市场推广费-其他",
        "会务费-会务费hh",
        "宣传费-物料ping"
      ];
      this.columns = columns;
      this.showPicker = true;
      console.log("demo");
    }
  }
};
</script>

<style scoped>
@import "./index.css";
</style>
